const path = require("path");
const commonConfig = require("./webpack.common");
const { merge } = require("webpack-merge");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");

/**
 * @type { import('webpack').Configuration }
 */
const config = {
  mode: "none",
  optimization: {
    minimize: true,
    splitChunks: {
      chunks: "all",
    },
    usedExports: true,
    mergeDuplicateChunks: true,
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, "public/index.html"),
      title: "拉钩教育",
      minify: {
        collapseWhitespace: true,
        minifyCSS: true,
        minifyJS: true,
        removeComments: true,
        minifyURLs: true,
      },
    }),
  ],
};

module.exports = merge(commonConfig, config);
